﻿"use strict";

function Server()
{
    this.online = false;
    this.url = 'http://CINDY-HP:8080';
    this.lastmsg = null;
    this.socket = io.connect(this.url);
    this.socket.on('connect', this.On_Connect);
    this.socket.on('disconnect', this.On_Disconnect);
    this.socket.on('msg', this.On_Message);

    this.socket.on('connect', function () {
        this.online = true;
        log('You have connected to ' + this.url);
    });

    this.socket.on('disconnect', function () {
        this.online = false;
        log('You have disconnected from ' + this.url);
    });

    this.socket.on('msg', function (msg) {
        this.lastmessage = msg;
        log('RECV< ' + msg.toString());
    });

    this.send = function (msg) {
        log('SEND> ' + msg.toString());
        this.socket.emit('msg', msg);
    }
}

